<template>
  <div class="topic">
<van-pull-refresh v-model="isLoading" @refresh="onRefresh">
  <ul>
      <li v-for="item in dataArr" :key="item.id">
        <!-- 懒加载标签 -->
        <img v-lazy="item.scene_pic_url" alt="" />
        <h3>{{ item.title }}</h3>
        <h4>{{ item.subtitle }}</h4>
        <p>{{ item.price_info | formatMoney }}</p>
      </li>
    </ul>
</van-pull-refresh>

    
    
    <!--分页  -->
    <van-pagination
      v-model="page"
      :page-count="pageCount"
      mode="simple"
      @change="changePage"
    />
  </div>
</template>
<script>
// 引入专题页接口
import { getTopicData } from "@/utils/http";

export default {
  name: "Topic",
  data() {
    return {
      page: 1, //默认页数
      size: 10, //默认每页数据的条数
      dataArr: [], //当前页面的数据
      pageCount: 0, //总页数
       isLoading: false,
    };
  },
  components: {},
  methods: {
    changePage() {
    //   console.log(this.page);
      this.getData();
    },
    getData() {
      getTopicData({
        page: this.page,
        size: this.size,
      }).then((res) => {
        // console.log(res);
        var { data, currentPage, totalPages } = res.data.data;
        this.dataArr = data;
        this.page = currentPage;
        this.pageCount = totalPages;
      });
    },
     onRefresh() {
      setTimeout(() => {
        
        this.isLoading = false;
        this.count++;
      }, 1000);
    },
  
  },
  created() {
    // 初始化请求数据
    this.getData();
  },
  mounted() {},
  updated() {},
};
</script>
<style scoped lang='less'>
.topic {
  img {
    width: 100%;
    display: block;
  }

  h3 {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    margin: 15px 0;
  }
  h4 {
    font-size: 0.42667rem;
    margin: 20px 0;
    color: #1f1f1f;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }
  p {
    color: #9b0000;
    margin-bottom: 20px;
    font-size: 16px;
    text-align: center;
  }
  /deep/.van-pagination__page-desc {
    display: none;
  }
  padding-bottom: 50px;
}
</style>